package com.atguigu.homework.exer.e1;

import java.util.Comparator;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/13 16:52
 * @注释
 */
public class ArrayTools {
    /**
     * 实现给对象数组从小到大排序，
     * 要求元素的运行时类型必须实现Comparable接口
     * @param arr
     */
    public static void sort(Comparable[] arr){
        for(int i=0; i<arr.length-1; i++){
            for(int j=0; j<arr.length-1; j++){
                if(arr[j].compareTo(arr[j + 1]) > 0){
                    Comparable temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
    }
    public static void sort1(Object[] arr, Comparator c){
        /*Employee emp = (Employee)arr.;
        Employee emp1 = (Employee)c;*/
        Employee e = new Employee();
        for(int i=0; i<arr.length-1; i++){
            for(int j=0; j<arr.length-1; j++){

            }
        }
    }
    /**
     * 使用foreach循环遍历输出数组元素
     * @param arr
     */
    public static void print(Object[]arr){
        //Object o = e1
        for (Object o : arr) {
            System.out.println(o.toString());
        }
    }
}
